﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KPIS.GERP.GFMS.MODEL;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.IDAL;
using KPIS.GERP.GFMS.DALFactory;

// test only
using KPIS.GERP.GFMS.DAL;

namespace KPIS.GERP.GFMS.BLL
{
    [Serializable]
    public class B_FIM_MAS_Contacts : IBLL_FIM_MAS_Contacts
    {
        Common common = new Common();
        private static readonly IDAL_FIM_MAS_Contacts dal = DataAccess.Create_FIM_MAS_Contacts();
        //D_FIM_MAS_Receives r = new D_FIM_MAS_Receives();

        public B_FIM_MAS_Contacts()
        {
            
        }

        public IList<M_FIM_MAS_Contacts> GetFull()
        {
            return dal.GetFull();
        }

        public IList<M_FIM_MAS_Contacts> GetList(string filter)
        {
            return dal.GetList(filter);
        }

        public IList<M_FIM_MAS_Contacts> GetListOffer(string icm_bid_seq, string contact_seq, string filter)
        {
            Nullable<int> nicm_bid_seq = common.ConvertNullInt(icm_bid_seq);
            Nullable<int> ncontact_seq = common.ConvertNullInt(contact_seq);

            return dal.GetListOffer(nicm_bid_seq, ncontact_seq, filter);
        }

        public IList<M_FIM_MAS_Contacts> GetListAR(string filter)
        {
            return dal.GetListAR(filter);
        }

        public M_FIM_MAS_Contacts GetInfo(string seq)
        {
            int nSeq;
 
            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetInfo(nSeq);
            }
            else
            {
                return null;
            }
        }

        public M_FIM_MAS_Contacts GetAddressInfo(string seq)
        {
            int nSeq;

            if (seq == null)
                return null;

            if (common.IsNumeric(seq))
            {
                nSeq = int.Parse(seq);
                return dal.GetAddressInfo(nSeq);
            }
            else
            {
                return null;
            }
        }


        public void Insert(M_FIM_MAS_Contacts info)
        {
            try
            {
                dal.Insert(info);
            }
            catch
            {
                throw;
            }
        }

        public void Update(M_FIM_MAS_Contacts info)
        {
            try
            {
                dal.Update(info);
            }
            catch
            {
                throw;
            }
        }

        public void Delete(M_FIM_MAS_Contacts info)
        {
            try
            {
                dal.Delete(info);
            }
            catch
            {
                throw;
            }
        }
    }
}
